*run this file on the dataset of results from estimating separate country-year regressions for stage one
*in order to estimate a prais-winsten regression, country-year results for duplicate survey country-years (i.e., more than one survey was available for that country-year) must be removed.
use "D:\data\Table3Model2_FirstStagefixedeffects_withlevel2indicators.dta"
drop if survcnty = 1999103
drop if survcnty == 1999103
drop if survcnty == 1999121
drop if survcnty == 1999145
drop if survcnty == 1999149
drop if survcnty == 1999150
drop if survcnty == 1999122
drop if survcnty == 1996149
save "D:\data\sTable3Model2_FirstStagefixedeffects_withlevel2indicators_droppeddupeyrs.dta", replace
tsset cnty year, yearly
prais  const_  lngdp100 ginicalc ginimiss rea_pac reur_cas rlac rme_na rpostc_e, robust
prais  const_  lngdp100 ginicalc  kg rea_pac reur_cas rlac rme_na rpostc_e, robust
prais  sdcented  lngdp100 ginicalc  kg rea_pac reur_cas rlac rme_na rpostc_e, robust
clear
use "D:\data\Table3Model3_FirstStagefixedeffects_withlevel2indicators.dta"
drop is survcnty = 1999103
drop if  survcnty = 1999103
drop if  survcnty == 1999103
drop if  survcnty == 1999121
drop if  survcnty == 1999122
drop if  survcnty == 1999145
drop if  survcnty == 1999149
drop if  survcnty == 1999150
save "D:\data\Table3Model3_FirstStagefixedeffects_withlevel2indicators_droppeddupeyrs.dta"
tsset cnty year, yearly
xtpcse  const_  lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e
xtreg  const_  lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
xtreg  const_  l.const_ lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
xtreg   sdcentin  lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
xtreg   sdcentin  l.sdcentin lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
xtreg   sdcented  lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
xtreg   sdcented l.sdcented  lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
xtreg  const_  l.const_ lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
outreg using laggedymodels.txt
xtreg   sdcentin  l.sdcentin lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
outreg using laggedymodels.txt, append
xtreg   sdcented l.sdcented  lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
outreg using laggedymodels.txt, append
xtreg   sdcented l.sdcented  lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
xtreg   sdcentin  l.sdcentin lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
xtreg  const_  l.const_ lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
xtreg  const_  lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
prais  const_  lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
prais   sdcentin  lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
prais    sdcented  lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
prais  const_  lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
outreg using "model3prais.txt"
prais   sdcentin  lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
outreg using "model3prais.txt", append
prais    sdcented  lngdp100 ginicalc kg rea_pac reur_cas rlac rme_na rpostc_e, robust
outreg using "model3prais.txt", append
